package file.day9_18.day02;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Test03环绕 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String line = "";


        try(
                FileOutputStream fos = new FileOutputStream("dos.txt",true);
                //io类 InputStream 或 OutputStream 都直接或者间接实现了AutoCloseable接口.
                //自动关闭流操作
        ){
            do {
                System.out.println("请输入内容：");
                line = scanner.nextLine();
                if(line.contains("exit")){
                    System.out.println("已退出输入");
                    break;
                }
                byte[] data = line.getBytes(StandardCharsets.UTF_8);
                fos.write(data);
                System.out.println("写出完成");

            }while (true);

        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}

